/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package fr.p10.miage.car1.mvc_struts.contoleur;

import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;

/**
 *
 * @author yousim
 */
public class LoginActionForm extends ActionForm{
    private String login;
    private String password;
    private String statut;

  
   public LoginActionForm() {
   }

   public LoginActionForm(String login, String password, String statut) {
      this.login = login;
      this.password = password;
      this.statut = statut;
   }
 
   public String getLogin() {
      return login;
   }

   public String getPassword() {
      return password;
   }

   public void setPassword(String password) {
      this.password = password;
   }

   public String getStatut() {
      return statut;
   }

   public void setStatut(String statut) {
      this.statut = statut;
   }


    /**
     * This is the action called from the Struts framework.
     *
     * @param mapping The ActionMapping used to select this instance.
     * @param request The HTTP Request we are processing.
     * @return
     */
    public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
        ActionErrors errors = new ActionErrors();
        if (getLogin() == null || getLogin().length() < 1) {
            errors.add("login", new ActionMessage("error.login"));
            //TODO: add 'error.name.required' key to your resources
        }
        if (getPassword() == null || getPassword().length() < 1) {
            errors.add("mdp", new ActionMessage("error.mdp"));
            //TODO: add 'error.name.required' key to your resources
        }
        return errors;
    }
}
